<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>欢迎页面-小螺号</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script type="text/javascript" src="./js/jquery-2.1.1.min.js" ></script>
		<link rel="stylesheet" href="./lib/layui/css/layui.css" />
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>

		<!-- upload photo -->
		<script type="text/javascript" src="js/common.js"></script>
		<link rel="stylesheet" href="../Shop/dist/lib/weui.min.css" />
		<link rel="stylesheet" href="../Shop/dist/css/jquery-weui.min.css" />
	    <script type="text/javascript" src="../Shop/dist/js/jquery-weui.js" ></script>

		<!--<script type="text/javascript" src="js/jquery.ztree.all-3.5.min.js" ></script>-->
		<!--<script type="text/javascript" src="js/category_selecter.js"></script>-->
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>
	<style>
		.mt20 {
			margin-top: 20px;
		}
		#photo1_show {
			width: 95px;
			height: 95px;
		}
		#photo2_show img {
			width: 150px;
			padding: 10px;
		}
		form {
				margin: 0;
			}
			textarea {
				display: block;
			}
	</style>
	<script>
		$("input").click(function(){
				
				if($('#type1').is(":checked")){
					$(".msbox").hide();
					alert("111");
				}
				else{	
					$(".msbox").show();
				}
		})
		</script>
	<body>
		<div class="x-body">

			<form class="layui-form" action="">
				<div class="layui-tab">
					
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-form-item">
								<label class="layui-form-label">商品货号</label>
								<div class="layui-input-inline">
									<input type="text" name="goodsNumber" class="layui-input" value="白001">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商品标题</label>
								<div class="layui-input-block">
									<input type="text" name="goodsTitle" class="layui-input" value="商品标题商品标题商品标题商品标题">
								</div>
							</div>
							<div class="layui-form-item gtype-select">
								<label class="layui-form-label">商品类型</label>
								<div class="layui-input-block">
									<i style="line-height: 36px;" class="select-1"><img src="images/glist-icon-on.png" width="21"/><span style="font-size: 14px;padding:0px 20px 0px 10px;">普通商品</span></i>
									<i style="line-height: 36px;" class="select-2"><img src="images/glist-icon.png" width="21"/><span style="font-size: 14px;padding:0px 20px 0px 10px;">秒杀商品</span></i>
								</div>	
							</div>
							
							<div class="msbox">
								<div class="layui-form-item ">
									<label class="layui-form-label">秒杀价格</label>
									<div class="layui-input-inline">
										<input type="text" name="ms-Price" class="layui-input" value="100">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">战报预设数量</label>
									<div class="layui-input-inline">
										<input type="text" name="ms-num" class="layui-input" value="100">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">秒杀销售数量</label>
									<div class="layui-input-inline">
										<input type="text" name="ms-salenum" class="layui-input" value="100">
									</div>
								</div>
								<div class="layui-form-item ">
									<label class="layui-form-label">秒杀时间</label>
									<div class="layui-input-inline">
										<!--<input class="layui-input" placeholder="开始日" name="start" id="start">-->
										<input type="text" class="layui-input" id="ms-start" placeholder="开始时间">
									</div>
									<div class="layui-input-inline">
										<!--<input class="layui-input" placeholder="截止日" name="end" id="end">-->
										<input type="text" class="layui-input" id="ms-end" placeholder="结束时间">
									</div>
								</div>
							</div>
		
							<script>
							/*商品类型选择*/
							$(function() {
								$(".msbox").hide();
								$(".gtype-select i").click(function(obj) {
									if($(this).hasClass("select-2")) {
					
										$(this).find("img").attr("src", "images/glist-icon-on.png"); 
										$(this).siblings('i').find("img").attr("src", "images/glist-icon.png"); 
										$(".msbox").show();
									} 
									else if($(this).hasClass("select-1"))
									{   
										
										$(this).find("img").attr("src", "images/glist-icon-on.png"); 
										$(this).siblings('i').find("img").attr("src", "images/glist-icon.png"); 
										$(".msbox").hide();
									}
								});
							});
						    </script>

							
							
							
							<div class="layui-form-item">
								<label class="layui-form-label">是否上架</label>
								<div class="layui-input-block">
									<input type="checkbox" name="switch" lay-skin="switch" checked="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">上传封面</label>
								<div class="layui-input-block">
									<img class="layui-upload-img" id="photo1_show" src="images/default-img.png">
									<p id="demoText"></p>
									<button type="button" class="layui-btn mt20" id="photo1" ><i class="layui-icon"></i>上传图片</button>
								</div>
								<div class="layui-input-block">
									<button type="button" class="layui-btn mt20" id="test5"><i class="layui-icon"></i>上传视频</button>
								</div>
							</div>
						</div>
						
						
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
		<script type="text/javascript">
			//weui多图上传
		    $(function(){
		        var tmpl_1 = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
		            $gallery_1 = $("#gallery_1"), $galleryImg_1 = $("#galleryImg_1"),
		            $uploaderInput_1 = $("#uploaderInput_1"),
		            $uploaderFiles_1 = $("#uploaderFiles_1"),
		            $gallerydel_1 = $(".weui-gallery__opr");
		
		        $uploaderInput_1.on("change", function(e){
		            var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
		            for (var i = 0, len = files.length; i < len; ++i) {
		                var file = files[i];
		
		                if (url) {
		                    src = url.createObjectURL(file);
		                } else {
		                    src = e.target.result;
		                }
		
		                $uploaderFiles_1.append($(tmpl_1.replace('#url#', src)));
		            }
		        });
		        $uploaderFiles_1.on("click", "li", function(){
		            $galleryImg_1.attr("style", this.getAttribute("style"));
		            $gallery_1.fadeIn(100);
		            $(this).addClass("on");//给当前查看图片添加class样式
		            var str1 =  $(this); 
		            $gallerydel_1.on("click", function(){
			            if (str1.hasClass("on")) 
			            {
			            	str1.remove();
			            } 
			            else
			            {	
			            }
				        $gallery_1.fadeOut(100);
		            });
		            
		        });

		        $gallery_1.on("click", function(){
		            $gallery_1.fadeOut(100);
		        });   
		    });
		    
		    //weui多图上传
		    $(function(){
		    	
		        var tmpl = '<li class="weui-uploader__file"  style="background-image:url(#url#)"></li>',
		            $gallery = $("#gallery"), $galleryImg = $("#galleryImg"),
		            $uploaderInput = $("#uploaderInput"),
		            $uploaderFiles = $("#uploaderFiles"),
		            $gallerydel = $(".weui-gallery__opr");
		
		        $uploaderInput.on("change", function(e){
		        	
		            var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
		            for (var i = 0, len = files.length; i < len; ++i) {
		                var file = files[i];
 					
		                if (url) {
		                    src = url.createObjectURL(file);
   
		                } else {
		                    src = e.target.result;
		                }
		                
		                
		                $uploaderFiles.append($(tmpl.replace('#url#', src)));
		               
		                
		                $(this).parent().siblings("ul").children("li").each(function(index, item){
						    $(item).attr('id', 'img-' + index);//给li添加上id
						});
		            }   
		        });
		        $uploaderFiles.on("click", "li", function(){
		            $galleryImg.attr("style", this.getAttribute("style"));
		            $(this).addClass("on");//给当前查看图片外侧li添加class样式
		            
		            $gallery.fadeIn(100);
		          
		           
		            var str =  $(this); 
		            $gallerydel.on("click", function(){
			            if (str.hasClass("on")) 
			            {
			            	str.remove();
			            } 
			            else
			            {	
			            }
				        $gallery.fadeOut(100); 
		            });

		            //退出查看图片移除on样式
		             $gallery.on("click", function(){
			        	str.removeClass("on");
			            $gallery.fadeOut(100);       
			        });   
		        });

		       
		    });
		</script>
		<script>
			layui.use(['form', 'layer', 'element'], function() {
				$ = layui.jquery;
				var form = layui.form,
					var element = layui.element,
						layer = layui.layer;

				//监听提交
				form.on('submit(add)', function(data) {
					console.log(data);
					//发异步，把数据提交给php
					layer.alert("增加成功", {
						icon: 6
					}, function() {
						// 获得frame索引
						var index = parent.layer.getFrameIndex(window.name);
						//关闭当前frame
						parent.layer.refresh(index);
						
						var index1 = parent.parent.layer.getFrameIndex(window.name);
						//关闭当前frame
						//parent.layer.refresh(index1);
	
					});
					return false;
				});
				
 				
 				
			});
		</script>

		<script>
			layui.use('laydate', function() {
				var laydate = layui.laydate;
				//常规用法
				laydate.render({
					elem: '#start'
				});
				
				//执行一个laydate实例
		        laydate.render({
		          elem: '#end' //指定元素
		        });
		        
		        
		        //秒杀开始
				laydate.render({
				    elem: '#ms-start'
				    ,type: 'datetime'
				});
				
				//秒杀结束
				laydate.render({
				    elem: '#ms-end'
				    ,type: 'datetime'
				});
				  
				  
				 
			});
			
			
		</script>

	</body>

</html>